<?php get_instance()->view('common/header');?>
<body>
<div class="shopshow">
    <div class="shopshowcons">
        <div class="swiper-slide-item" >
            <?php if (!empty($list['desc'])):?>
            <div class="waper m0a hengline vCenter bqwp3box">
                <?php foreach ($list['desc'] as $dk => $dv):?>
                    <b class="bqwp3"><?php echo $dv['tags'].'('.$dv['count'].')'?></b>
                <?php endforeach;?>
            </div>
            <?php endif;?>
            <?php if (!empty($list['list'])):?>
                <div class="list">
                    <?php foreach ($list['list'] as $k => $v):?>
                        <div class="userhuifu bor_bb">
                            <div class="hengleft">
                                <div class="minuserimg imgbox"><img src="<?php echo $v['headurl']?>" alt=""></div>
                                <div class="">
                                    <h1><?php echo $v['name']?></h1>
                                    <p class="f07 pjdatatime"><?php echo $v['addtime']?></p>
                                </div>
                            </div>
                            <div class="huifu">
                                <p class="m5_0 f09"><?php echo $v['content']?></p>
                                <?php if (!empty($v['imgs'])):?>
                                    <div class="huifuimgbox imgboxpull">
                                        <?php foreach ($v['imgs'] as $cik => $civ):?>
                                            <div class=" imgbox"><img src="<?php echo $civ?>" alt=""></div>
                                        <?php endforeach;?>
                                    </div>
                                <?php endif;?>
                                <?php if (isset($v['desc'])):?>
                                    <p class="textEll  cor9">
                                        <span class="f08 mr15"><?php echo $v['desc']?></span>
                                    </p>
                                <?php endif;?>
                            </div>
                            <?php if (!empty($v['reply'])):?>
                                <div class="shophuifu">
                                    <span>店家回复：</span><?php echo $v['reply']?>
                                </div>
                            <?php endif;?>
                            <div class="xing heng vCenter">
                                <?php for ($w = 0; $w < $v['score']; $w++):?>
                                    <img src="<?php echo $this->staticUrl?>img/png/pic11.png" alt="">
                                <?php endfor; $xw = 5 - $v['score']; for ($x = 0; $x < $xw; $x++):?>
                                    <img src="<?php echo $this->staticUrl?>img/png/pic12.png" alt="">
                                <?php endfor;?>
                            </div>
                        </div>
                    <?php endforeach;?>
                </div>
            <?php else:?>
                <div class="statebox chuizhi jdjz" style="flex: 1;height: 100%;">
                    <img class="stateimgda mb5" src="<?php echo $this->staticUrl?>img/default/2.png" alt="">
                    <span class="f09 cor9 tc mb20">暂无评论</span>
                </div>
            <?php endif;?>
            <div class="weui-loadmore" style="display: none">
                <div class="load">
                    <i class="weui-loading"></i>
                    <span class="weui-loadmore__tips">正在加载</span>
                </div>
                <span class="noC" style="display: none">没有更多内容了~</span>
            </div>
        </div>
    </div>
</div>
</body>
<script src="<?php echo $this->staticUrl?>js/base.js"></script>
<script src="<?php echo $this->staticUrl?>js/jquery-weui.js"></script>
<script type="text/javascript">
    $(function () {
        var page = 1,
            merchantId = "<?php echo $merchantId?>",
            productId = "<?php echo $productId?>";
        var loading = false;  //状态标记
        $(document.body).infinite().on("infinite", function() {
            if(loading) return;
            loading = true;
            $(".weui-loadmore").show();
            $(".load").show();
            $(".noC").hide();
            $.ajax('<?php echo getUrl('product/getCommentList');?>', {
                type:'post',
                data:{merchant_id:merchantId,product_id:productId,page:page},
                dataType:'json',
                error:function(){
                    show_message({status:0, message:'请求超时'});
                },
                timeout:60000,
                success:function(e,textStatus,jqXHR){
                    loading = false;
                    var list = e.data.list;
                    if (!list.length){
                        $(document.body).destroyInfinite();
                        $(".load").hide();
                        $(".noC").show();
                        return;
                    }
                    page += 1;
                    $(".weui-loadmore").hide();
                    var html,
                        lImg = "<?php echo $this->staticUrl?>img/png/pic11.png",
                        aImg = "<?php echo $this->staticUrl?>img/png/pic12.png"
                        ;
                    $.each(list, function (key, obj) {
                        var imgs = '', desc = '', reply = '', xing = '', score = 5 - obj.score;
                        if (obj.imgs.length){
                            imgs = '<div class="huifuimgbox imgboxpull">';
                            $.each(obj.imgs, function (k, v) {
                                imgs += '<div class=" imgbox"><img src="'+v+'" alt=""></div>';
                            });
                            imgs += '</div>';
                        }
                        if (obj.desc.length){
                            desc = '<p class="textEll  cor9">' +
                                '   <span class="f08 mr15">'+obj.desc+'</span>' +
                                '</p>'
                        }
                        if (obj.reply.length){
                            reply = '<div class="shophuifu"><span>店家回复：</span>'+obj.reply+'</div>';
                        }
                        for (var i = 0; i < obj.score; i++){
                            xing += '<img src="'+lImg+'" alt="">';
                        }
                        for (var j = 0; j < score; j++){
                            xing += '<img src="'+aImg+'" alt="">';
                        }

                        html =
                            '<div class="userhuifu bor_bb">' +
                            '   <div class="hengleft">' +
                            '       <div class="minuserimg imgbox"><img src="'+obj.headurl+'" alt=""></div>' +
                            '       <div class=""><h1>'+obj.name+'</h1>' +
                            '           <p class="f07 pjdatatime">'+obj.addtime+'</p>' +
                            '       </div>' +
                            '   </div>' +
                            '   <div class="huifu">' +
                            '       <p class="m5_0 f09">'+obj.content+'</p>' + imgs + desc +
                            '   </div>' + reply +
                            '   <div class="xing heng vCenter">' + xing +
                            '   </div>' +
                            '</div>';
                        $(".list").append(html);
                    });
                }
            });
        });
    })
</script>
</html>